package com.windowes.weichang.controller.platform;

import com.windowes.weichang.access.AccessLimit;
import com.windowes.weichang.common.ServerResponse;
import com.windowes.weichang.dto.StaffDTO;
import com.windowes.weichang.service.StaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/***
 *
 * @author: yangqing
 * @email: qing.yang@bangdao-tech.com
 * @createTime: 2018/7/28 下午7:28
 * @description: 员工列表
 *
 **/

@RestController
@RequestMapping("staff")
public class StaffController {


    @Autowired
    StaffService staffService;


    @AccessLimit(manageUser = true)
    @PostMapping("addOrUpdate")
    public ServerResponse addOrUpdate(@RequestBody StaffDTO staff) {
        return staffService.addOrUpdate(staff);
    }

    @AccessLimit(manageUser = true)
    @GetMapping("list")
    public ServerResponse list(@RequestParam(value = "pageNo", defaultValue = "1") int pageNo,
                               @RequestParam(value = "pageSize", defaultValue = "15") int pageSize) {
        return staffService.listStaff(pageNo, pageSize);
    }

    @AccessLimit(manageUser = true)
    @PostMapping("limitLogin")
    public ServerResponse limit(Integer userId, Boolean limit) {
        return staffService.limit(userId, limit);
    }




}
